/*
 * #%L
 * com.linkwithweb.products.swiftui.plugins.HelloWorldPlugin
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2011 - 2012 Linkwithweb
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */
/**
 * 
 */
package com.linkwithweb.products.swiftui.plugins;

import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;

import org.java.plugin.registry.Extension;
import org.java.plugin.registry.ExtensionPoint;
import org.java.plugin.registry.Extension.Parameter;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author ashwin kumar
 * 
 */
@Plugin
public class AccordianMenuPlugin extends AbstractSwiftUIPlugin {

	public AccordianMenuPlugin() {
		System.out.println("In Constructor");
	}

	/**
	 * 
	 */
	public void sayHello() {
		System.out.println("Hello World from plugin.....");

		ExtensionPoint toolExtPoint = getManager().getRegistry().getExtensionPoint(getDescriptor().getId(), "Tool");
		for (Iterator it = toolExtPoint.getConnectedExtensions().iterator(); it.hasNext();) {
			Extension ext = (Extension) it.next();
			Parameter descrParam = ext.getParameter("description");
			Parameter iconParam = ext.getParameter("icon");
			URL iconUrl = null;
			if (iconParam != null) {
				iconUrl = getManager().getPluginClassLoader(ext.getDeclaringPluginDescriptor()).getResource(
						iconParam.valueAsString());
			}
		}

	}
	
	/**
	 * @param pluginContext
	 * @return
	 */
	@RequestMapping("/test")
	public ModelAndView testMethod(SwiftUIPluginContext pluginContext) {
		return pluginModelAndView("test", new HashMap());
	}




}
